package com.example.book;

import com.example.book.dao.TUserMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.InputStream;
import java.util.Date;

public class MybatisDaoTest1 {
    SqlSession session;

    @Before
    public void beforeLoadXML() {
        InputStream inputStream = MybatisDaoTest1.class.getClassLoader().getResourceAsStream("mybatis-configuration.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        session = sqlSessionFactory.openSession();
    }

    @Test
    public void test_1() {
        TUserMapper mapper = session.getMapper(TUserMapper.class);
        Date oo = mapper.selectNow();
        System.out.println(oo);
    }

    @After
    public void closeSession() {
        session.close();
    }
}
